﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SBlogCore.Common.FriendlyException
{
    [SkipScan]
    public static class SBlogCoreException
    {
        public static Exception Say(string errorMessage, params object[] args)
        {
            return new AppFriendlyException(FormatErrorMessage(errorMessage,args),default);
        }
        public static Exception Empty(string key)
        {
          return  Say($"{key} 不能为空！");
        }
        /// <summary>
        /// 格式化错误消息
        /// </summary>
        /// <param name="errorMessage">错误消息</param>
        /// <param name="args">格式化参数</param>
        /// <returns></returns>
        internal static string FormatErrorMessage(string errorMessage, params object[] args)
        {
            return args == null || args.Length == 0 ? errorMessage : string.Format(errorMessage, args);
        }
    }
}
